package com.jf.ai.service;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.vectorstore.QuestionAnswerAdvisor;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2025-07-08
 * Time:0:14
 */
@Service
public class RagService {
    private final ChatClient chatClient;
    private final VectorStore vectorStore;
    public RagService(ChatClient.Builder chatBuilder, VectorStore vectorStore) {
        this.chatClient = chatBuilder.build();
        this.vectorStore = vectorStore;
    }

    public String simpleRag(String query) {
        return chatClient.prompt().user(query).advisors(new QuestionAnswerAdvisor(vectorStore)).call().content();
    }

    public String simpleChat(String query) {
        return chatClient.prompt().user(query).call().content();
    }
}
